﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AdminPermissions.aspx.cs"
         Inherits="TaskWebApplicationUI.AdminPermissions" Theme="TaskTheme" ValidateRequest="false"
         MasterPageFile="WebTasksMaster.Master" %>
<%@ Import Namespace="TaskKernel.Domain" %>


<%@ Register Assembly="Microsoft.Practices.Web.UI.WebControls" Namespace="Microsoft.Practices.Web.UI.WebControls"
             TagPrefix="pp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MasterPagePlaceHolder" runat="Server">
    <pp:objectcontainerdatasource id="ObjectContainerDataSource1" runat="server" 
                                  ondeleted="ObjectContainerDataSource1_Deleted" onupdated="ObjectContainerDataSource1_Updated" />
    <p style="text-align: center;">
        <asp:Label ID="Department" SkinID="Department" runat="server" Text="Название отдела"></asp:Label>
    </p>
    <table class="spisok">
        <tr>
            <td>
                <asp:DropDownList ID="AccountDDL" runat="server" DataTextField="FullName" DataValueField="UID"
                                  CssClass="bodyt">
                </asp:DropDownList>
            </td>
            <td>
                <asp:DropDownList ID="RoleDDL" runat="server" CssClass="bodyt">
                    <asp:ListItem Value="Executor">Ответственный</asp:ListItem>
                    <asp:ListItem Value="Admin">Администратор</asp:ListItem>
                    <asp:ListItem Value="AdminWithoutMessage">Администратор без сообщений</asp:ListItem>
                    <asp:ListItem Value="Participant">Авт.участник</asp:ListItem>
                </asp:DropDownList>
            </td>
            <td>
                <asp:LinkButton ID="LinkButton3" runat="server" OnClick="LinkButton3_Click">Добавить</asp:LinkButton>
            </td>
        </tr>
    </table>
    <hr />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Label ID="Label1" runat="server" ForeColor="Red" CssClass="bodyt"></asp:Label>
            <br />
            <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectContainerDataSource1"
                          BorderWidth="1px" CssClass="grid-view" GridLines="None" CellPadding="4" BorderStyle="None"
                          AllowSorting="True" DataKeyNames="UID">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID="UID" runat="server" Text='<%#Eval("UID")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Пользователь">
                        <ItemTemplate>
                            <asp:Label ID="Login" runat="server" Text='<%#Eval("User.FullName")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Роль" SortExpression="Role">
                        <ItemTemplate>
                            <asp:Label ID="Role" runat="server" Text='<%#Tools.RoleEnumDescription((RoleEnum) Eval("Role"))%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="Role" runat="server" SelectedValue='<%#Bind("Role")%>'>
                                <asp:ListItem Value="Executor">Ответственный</asp:ListItem>
                                <asp:ListItem Value="Admin">Администратор</asp:ListItem>
                                <asp:ListItem Value="AdminWithoutMessage">Администратор без сообщений</asp:ListItem>
                                <asp:ListItem Value="Participant">Авт.участник</asp:ListItem>
                            </asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                            Text="Изменить"></asp:LinkButton>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                                            Text="ОК"></asp:LinkButton>
                            &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                                  Text="Отмена"></asp:LinkButton>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton ID="Button2" runat="server" CausesValidation="False" CommandName="Delete"
                                            Text="Удалить" OnClientClick="return confirm('Удалить ?');" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EditRowStyle HorizontalAlign="Right" />
                <RowStyle HorizontalAlign="Right" />
            </asp:GridView>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>